import Vue from 'vue';
import Router from 'vue-router';
import Layout from '../layout/index.vue';

Vue.use(Router);

export const constantRouterMap = [
    {
        path: '/login',
        component: () => import('@/views/login/index'),
        meta: {
            title: '登录',
        }
    },
    {
        path: '/404',
        component: () => import('@/views/404'),
        meta: {
            title: '404',
        }
    },
    {
        path: '/',
        component: Layout,
        redirect: '/login',
        children: [
            {
                path: "/carDispatch",
                title: '车辆调度管理',
                component: () => import('@/views/carDispatch/index'),
                children: [
                    {
                        path: '/carDispatch/short',
                        component: (resolve) => require(['@/views/carDispatch/short'], resolve),
                        name: 'short',
                        meta: {
                            title: '短途货运驾驶员列表',
                            ptitle: '车辆调度管理',
                            activeMenu: '2-2'
                        }
                    },
                    {
                        path: '/carDispatch/long',
                        component: (resolve) => require(['@/views/carDispatch/long/index.vue'], resolve),
                        name: 'long',
                        meta: {
                            title: '长途货运驾驶员列表',
                            ptitle: '车辆调度管理',
                            activeMenu: '2-1'
                        }
                    },
                    {
                        path: '/carDispatch/russia',
                        component: (resolve) => require(['@/views/carDispatch/russia/index.vue'], resolve),
                        name: 'russia',
                        meta: {
                            title: '俄罗斯驾驶员列表',
                            ptitle: '车辆调度管理',
                            activeMenu: '2-3'
                        }
                    },
                ]
            },
            {
                path: '/authority',
                component: () => import('@/views/authority/index.vue'),
                meta: {
                    title: '权限管理'
                },
                children: [
                    {
                        path: '/authority/users',
                        component: () => import('@/views/authority/users/index.vue'),
                        meta: {
                            title: '用户管理',
                            ptitle: '权限管理'
                        }
                    }
                ]
            }
        ]


    },
    {
        path: '/redirect',
        component: Layout,
        hidden: true,
        children: [
            {
                path: '/redirect/:path*',
                component: (resolve) => require(['@/views/redirect/index.vue'], resolve)
            }
        ]
    },
    {
        path: '/',
        component: Layout,
        redirect: '/dashboard',
        children: [{
            path: 'dashboard',
            component: (resolve) => require(['@/views/home/index.vue'], resolve),
            name: 'Dashboard',
            meta: {
                title: '首页',
                icon: 'index',
                affix: true,
                noCache: true,
                activeMenu: '1'
            }
        }]
    },
]
export default new Router({
    // mode: 'hash',
    mode: 'history',
    scrollBehavior: () => ({
        y: 0
    }),
    routes: constantRouterMap
})